package com.cat.test.test01;

import java.util.List;
import java.util.ListIterator;
import java.util.function.Consumer;

/**
 * @author 曲大人的喵
 * @description
 * @create 2025/10/25 20:31
 * @since JDK17
 */

public class InnerLoop {
    static <T> void hiOrder(List<T> list, Consumer<T> consumer) {
        ListIterator<T> iterator = list.listIterator(list.size());
        while (iterator.hasPrevious()) {
            T previous = iterator.previous();
            consumer.accept(previous);
        }
    }

    public static void main(String[] args) {
        List<Integer> list = List.of(1, 2, 3, 4, 5);
        hiOrder(list, o -> System.out.println(o));
    }
}
